/*
 * @Author: czy
 * @Date: 2021-04-04 22:39:40
 * @LastEditTime: 2021-04-11 23:14:01
 */

/**
 * @description: Get data from specified port.
 * @param port_from Input port.
 * @return Character entered.
 */
unsigned char inb(unsigned short int port_from)
{
    unsigned char data;
    __asm__ __volatile__("inb %w1,%0"
                         : "=a"(data)
                         : "Nd"(port_from));
    return data;
}

/**
 * @description: Output data from specified port.
 * @param port_to   Output port.
 * @param value     Character to be output.
 */
void outb(unsigned short int port_to, unsigned char value)
{
    __asm__ __volatile__("outb %b0,%w1"
                         :
                         : "a"(value), "Nd"(port_to));
}